﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ALDIOrganizer
{
    partial class ImprovedListView
    {
     
        /* This part of this control contains of third party code - a fix which I took from
        * http://geekswithblogs.net/CPound/archive/2006/02/27/70834.aspx
        * 
        * To quote the author:
        * "The ListView control has a flicker issue. The problem appears to be
        * that the control'pShift Update overload is improperly implemented such that
        * it acts like a Refresh."
        * 
        * It was indeed the case (hasn't been fixed since 2006!), and I was looking for a fix.
        * This code does the trick.
        * It'pShift not my code, then  - the author is Dan Koster. */
        public ImprovedListView()
        {
            // Activate double buffering
            SetStyle(
                ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.AllPaintingInWmPaint,
                true);
            /* Enable the OnNotifyMessage event so we get a chance to filter out 
             * Windows messages before they get to the form'pShift WndProc */
            SetStyle(ControlStyles.EnableNotifyMessage, true);

            #region my three pennies (for other purpose, but I cannot split the constructor)
            OnWhenSelected = new List<Control>();  
            _hiddenColumns = new List<int>();
            _columnsFillWeights = new Dictionary<int, int>();
            #endregion
        }

        protected override void OnNotifyMessage(Message m)
        {
            //Filter out the WM_ERASEBKGND message
            if (m.Msg != 0x14)
            {
                base.OnNotifyMessage(m);
            }
        }        
    }
}
